//package com.origin.src.datasource;
//
//import org.apache.shardingsphere.api.sharding.standard.PreciseShardingAlgorithm;
//import org.apache.shardingsphere.api.sharding.standard.PreciseShardingValue;
//import org.apache.shardingsphere.underlying.common.exception.ShardingSphereException;
//
//import java.nio.charset.StandardCharsets;
//import java.util.Collection;
//import java.util.zip.CRC32C;
//
//
//public class PreciseShardingAlgorithmCRC32 implements PreciseShardingAlgorithm {
//
//    public PreciseShardingAlgorithmCRC32(String prefix) {
//        this.prefix = prefix;
//    }
//
//    String prefix;
//
//    /**
//     * Sharding.
//     *
//     * @param availableTargetNames available data sources or tables's names
//     * @param shardingValue        sharding value
//     * @return sharding result for data source or table's name
//     */
//    @Override
//    public String doSharding(Collection availableTargetNames, PreciseShardingValue shardingValue) {
//
//        if (shardingValue.getValue() == null) {
//            throw new ShardingSphereException("sharding key can't be null,logicTableName="
//                    + shardingValue.getLogicTableName() +
//                    " columnName=" + shardingValue.getColumnName());
//        }
//
//        CRC32C crc32 = new CRC32C();
//        crc32.update(String.valueOf(shardingValue.getValue()).getBytes(StandardCharsets.UTF_8));
//        long crc32Value = crc32.getValue() % availableTargetNames.size();
//        return prefix + crc32Value;
//    }
//
//}
